<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=0.5, maximum-scale=0.5">
    <title>{$site.name}</title>
    <link rel="shortcut icon" href="{$logo}" />
    <!-- Bootstrap Core CSS -->
    <style type="text/css" media="all">
        * {
            margin: 0;
            padding: 0;
			
        }
		body{
			height:100%;
			/* background:linear-gradient(to bottom, #F8EBFF, #F8F8F8) no-repeat; */
			background:#fff;
			background-size: cover;
		}
        .on {
            font-size: 48px;
            font-weight: 600;
            color: #000;
            line-height: 84px;
            letter-spacing: 3px;
            margin-left:20px;
        }

        .btn {
            width: 690px;
            height: 76px;
            background: #48A264;
            border-radius: 38px;
            text-align: center;
            line-height: 76px;
            color: #ffffff;
            font-size: 30px;


        }

        .btn1 {
            width: 690px;
            height: 76px;
            background:#48A264;
            border-radius: 38px;
            text-align: center;
            line-height: 76px;
            color: #ffffff;
            font-size: 30px;
            margin: 10px auto;
        }
        .btn2 {
            width: 620px;
            height: 90px;
            background: #48A264;
            border-radius:45px;
            text-align: center;
            line-height:90px;
            color: #ffffff;
            font-size: 30px;
            margin: 10px auto;
        }
        .pos{
            width: 686px;
            height:96px;
            background: red;
            border: none;
            outline: none;
            font-size: 26px;
            text-align: center
        }
        
        .notclick {
            pointer-events: none;
        }
		.inputBox{
			background-color:#F3F3F3;
			margin:116px 50px 0 50px;
			border-radius: 50px;
			display: flex;
			align-items: center;
			padding:0 30px;
			
		}
		input{
			background-color:#F3F3F3;
		}
    </style>
    <style type="text/css">
        *{margin:0; padding:0;}
        a{text-decoration: none;}
        img{max-width: 100%; height: auto;}
        .weixin-tip{display: none; position: fixed; left:0; top:0; bottom:0; background: rgba(0,0,0,0.8); filter:alpha(opacity=80);  height: 100%; width: 100%; z-index: 100;}
        .weixin-tip p{text-align: center; margin-top: 10%; padding:0 5%;}
    </style>
    <script typet="text/javascript" src="/web/invite/invite.js"></script>
</head>

<body>
    <div style="margin-top: 150px;margin-left: 34px;text-align: center;">
        <img src="{$logo}" alt="" style="width: 241px;height: 216px;">
    </div>
    <div class="inputBox" >
		<img src="/web/invite/icon_phone.png" style="width:38px;height:38px;" alt="" />
        <input  type="text" id="phone" maxlength="11" placeholder="请输入您的手机号码" style="
        height: 96px;flex:1;border: none;outline: none;font-size: 32px;padding-left: 32px;">
    </div>
    <div class="inputBox" style="margin: 40px 50px;justify-content: space-between;">
		<img src="/web/invite/icon_set.png" style="width:38px;height:38px;" alt="" />
        <input type="text" id="captcha" placeholder="验证码" style="
        height: 96px;
        width: 50%;border: none;outline: none;font-size: 32px;">
        <div class="wp" style="font-size: 32px;color: #000000;padding-right: 20px;">获取验证码</div>
    </div>

    <div  class="inputBox" style="margin: 40px 50px; display: none;">
		<img src="/web/invite/icon_set.png" style="width:38px;height:38px;" alt="" />
        <input type="text"  id="init_code" placeholder="请输入您的专属邀请码(非必填)" style="width: 686px;
        height: 96px; border: none;outline: none;font-size: 32px;padding-left: 32px;" value="{$invite}" readonly>
    </div>
    <div style="text-align: center;margin-top: 30px;" >
        <div class="btn2" style="margin: 50px auto 10px;color:#48A264;border: 1px solid #48A264;"><span style="font-size: 26px;font-weight:bold;color: #fff;">立即注册</span></div>
    </div>
</body>

<script>
    $('.wp').click(function () {
        var wp = document.getElementsByClassName('wp')[0];

        var phone = $('#phone').val();
        if (!phone) {
            alert('请输入手机号');
            return;
        }
        let time = 60;
        $.ajax({
            url: "/api/sms/send",
            type: "post",
            dataType: "json",
            data: {mobile: phone, event: "register" },
            success: function (data) {
                if(data.code == 1){
                    $('.wp').addClass('notclick');
                }
                alert(data.msg);
            }
        });
        const timer = setInterval(() => {
            time--;
            if (time <= 0) {
                wp.innerHTML = "重新获取验证码"
                clearInterval(timer);
                $('.wp').removeClass('notclick');
            } else {
                if (time < 10) {
                    wp.innerHTML = "0" + time + "s后重新获取"
                } else {
                    wp.innerHTML = time + "s后重新获取"
                }
            }
            console.log(time);
        }, 1000);
    })

    
    $('.btn2').click(function () {
        var phone = $('#phone').val();
        var init_code = $('#init_code').val();
        if (!phone) {
            alert('请输入手机号');
            return;
        }
        var captcha = $('#captcha').val();
        if (!captcha) {
            alert('请输入验证码');
            return;
        }
        $.ajax({
            url: "/index/invite/register",
            type: "post",
            dataType: "json",
            data: { mobile: phone, captcha:captcha, invite_code:init_code},
            success: function (data) {
                alert(data.msg)
                console.log(data);
                if(data.code==1){
                    window.location.href = 'http://fir.jiangkukeji.cn/c1zb9axe';
                }
            },
            fail: function (msg) {
                alert(msg);

            }
        });
    })
</script>

</html>